﻿using UnityEngine;
using System.Collections;
using System;

public class ASNode:CompareAB<ASNode> {
    //needed attribute
    public int inOpenLs;//1 in open list ;2 in close list ; 0 neighter;
    public int FTotalCost// total cost = F = G + H;  "int" will make the programming run quicker;
    {
        get { return GCost + HCost; }
    }
    public int GCost;
    public int HCost;
    public ASNode parent; //parent node;
    public bool isObstacle;
    public Vector3 position;

    public ASNode()
    {
        this.inOpenLs = 0;
        this.GCost = 0;
        this.HCost = 0;
        this.parent = null;
        this.isObstacle = false;
        this.position = Vector3.zero;
    }

    public ASNode(Vector3 pos)
    {
        this.inOpenLs = 0;
        this.GCost = 0;
        this.HCost = 0;
        this.parent = null;
        this.isObstacle = false;
        this.position = pos;
    }

    public void maskObstacle()
    {
        this.isObstacle = true;
    }

    public void clearObstacle()
    {
        this.isObstacle = false;    
    }

    public bool GreaterThan(ASNode b)
    {
        return this.FTotalCost > b.FTotalCost;
    }

    public bool LessThan(ASNode b)
    {
        return this.FTotalCost < b.FTotalCost;
    }
}
